import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UpkeepPlanForm, UpkeepPlanQuery, UpkeepPlanVO } from '@/api/iot/upkeepPlan/types';

/**
 * 查询电梯保养计划列表
 * @param query
 * @returns {*}
 */

export const listUpkeepPlan = (query?: UpkeepPlanQuery): AxiosPromise<UpkeepPlanVO[]> => {
  return request({
    url: '/iot/upkeepPlan/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询电梯保养计划详细
 * @param planId
 */
export const getUpkeepPlan = (planId: string | number): AxiosPromise<UpkeepPlanVO> => {
  return request({
    url: '/iot/upkeepPlan/' + planId,
    method: 'get'
  });
};

/**
 * 新增电梯保养计划
 * @param data
 */
export const addUpkeepPlan = (data: UpkeepPlanForm) => {
  return request({
    url: '/iot/upkeepPlan',
    method: 'post',
    data: data
  });
};

/**
 * 修改电梯保养计划
 * @param data
 */
export const updateUpkeepPlan = (data: UpkeepPlanForm) => {
  return request({
    url: '/iot/upkeepPlan',
    method: 'put',
    data: data
  });
};

/**
 * 删除电梯保养计划
 * @param planId
 */
export const delUpkeepPlan = (planId: string | number | Array<string | number>) => {
  return request({
    url: '/iot/upkeepPlan/' + planId,
    method: 'delete'
  });
};
